package controle.gui.cadastro;

import java.awt.EventQueue;

import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.JPopupMenu;
import java.awt.Component;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JMenuItem;

public class JiCidade extends JInternalFrame {
	private JTextField textField;
	private JTextField textField_1;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JiCidade frame = new JiCidade();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public JiCidade() {
		setBounds(100, 100, 422, 131);
		
		JPanel panel = new JPanel();
		getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		textField = new JTextField();
		textField.setEditable(false);
		textField.setBounds(12, 25, 75, 23);
		panel.add(textField);
		textField.setColumns(10);
		
		JLabel lblCod = new JLabel("Cod");
		lblCod.setBounds(12, 12, 70, 14);
		panel.add(lblCod);
		
		JComboBox comboBox = new JComboBox();
		comboBox.setBounds(99, 25, 63, 23);
		panel.add(comboBox);
		
		JLabel lblNewLabel = new JLabel("Estado");
		lblNewLabel.setBounds(98, 12, 70, 14);
		panel.add(lblNewLabel);
		
		textField_1 = new JTextField();
		textField_1.setBounds(174, 25, 228, 23);
		panel.add(textField_1);
		textField_1.setColumns(10);
		
		JPopupMenu popupMenu = new JPopupMenu();
		addPopup(textField_1, popupMenu);
		
		JMenuItem mntmCidade = new JMenuItem("Cidade");
		mntmCidade.setMnemonic(KeyEvent.VK_1);
		popupMenu.add(mntmCidade);
		
		JLabel lblNewLabel_1 = new JLabel("Cidade");
		lblNewLabel_1.setBounds(174, 12, 70, 14);
		panel.add(lblNewLabel_1);
		
		JButton btnNovo = new JButton("Novo");
		btnNovo.setBounds(12, 60, 88, 24);
		panel.add(btnNovo);
		
		JButton btnSalvar = new JButton("Salvar");
		btnSalvar.setBounds(214, 60, 88, 24);
		panel.add(btnSalvar);
		
		JButton btnEditar = new JButton("Editar");
		btnEditar.setBounds(112, 60, 88, 24);
		panel.add(btnEditar);
		
		JButton btnExcluir = new JButton("Excluir");
		btnExcluir.setBounds(314, 60, 88, 24);
		panel.add(btnExcluir);

	}
	private static void addPopup(Component component, final JPopupMenu popup) {
		component.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				if (e.isPopupTrigger()) {
					showMenu(e);
				}
			}
			public void mouseReleased(MouseEvent e) {
				if (e.isPopupTrigger()) {
					showMenu(e);
				}
			}
			private void showMenu(MouseEvent e) {
				popup.show(e.getComponent(), e.getX(), e.getY());
			}
		});
	}
}
